package day05test;

import java.util.Arrays;
import java.util.Random;

public class MaxOfArray {
    public static void main(String[] args) {
        Random r = new Random();
        int[] arr = new int[5];
        for (int i = 0; i < arr.length; i++) {
            int guess = r.nextInt(100)+1;
            arr[i] = guess;
            System.out.print(guess + " ");
        }
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]){
                max = arr[i];
            }
        }
        System.out.println();
        System.out.println("最大值为" +max);

        Arrays.sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }

    }
}
